﻿

CREATE PROCEDURE [dbo].[fares_FiltreazaRaportFisaPartenerului] 
    @filtruPart varchar(8000),
    @filtruDoc varchar(8000),
	@data2 datetime,
	@CodUnitate smallint
AS
BEGIN
	-- SET NOCOUNT ON added to prevent extra result sets from
	-- interfering with SELECT statements.
	SET NOCOUNT ON;

  SELECT * FROM [fares_FisaPartenerului] WHERE 
    (LEN(LTRIM(RTRIM(@filtruPart)))=0 OR (IDPartener IN (SELECT fart.value FROM dbo.SplitBigIntParameters(@filtruPart,',') fart))) AND
    (LEN(LTRIM(RTRIM(@filtruDoc)))=0 OR (IDTipDocument IN (SELECT fart.value FROM dbo.SplitBigIntParameters(@filtruDoc,',') fart))) AND
 	CodUnitate = @CodUnitate AND [DataDoc]<=@data2
END